//
//  CHCameraUitl.m
//  SCCAProofSdk
//
//  Created by cyptt on 2022/3/11.
//

#import "CHCameraUitl.h"

@implementation CHCameraUitl

#pragma mark - 视频地址
+ (NSString *)getVideoPathCache
{
  NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString * videoCache = [[paths firstObject] stringByAppendingPathComponent:@"PROOF_SDK_FILE_NAME"];
  BOOL isDir = NO;
  NSFileManager *fileManager = [NSFileManager defaultManager];
  BOOL existed = [fileManager fileExistsAtPath:videoCache isDirectory:&isDir];
  if ( !(isDir == YES && existed == YES) ) {
    [fileManager createDirectoryAtPath:videoCache withIntermediateDirectories:YES attributes:nil error:nil];
  };
  return videoCache;
}
#pragma mark - 拼接视频文件名称
+ (NSString *)getVideoNameWithType:(NSString *)fileType
{
    NSTimeInterval now = [[NSDate date] timeIntervalSince1970];
    NSDateFormatter * formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"HHmmss"];
    NSDate * NowDate = [NSDate dateWithTimeIntervalSince1970:now];
    NSString * timeStr = [formatter stringFromDate:NowDate];
    
    NSString *fileName = @"";
    if ([fileType isEqualToString:@"jpg"] ||[fileType isEqualToString:@"png"]) {
        fileName = [NSString stringWithFormat:@"photo%@.%@",timeStr,fileType];
    }else{
        fileName = [NSString stringWithFormat:@"video_%@.%@",timeStr,fileType];
    }
    
    return fileName;
}

@end
